<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>src\cmpage\model\page_rec.js</title>
  
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
</head>
<body class="yui3-smart">
 <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
               <a class="navbar-brand mainlogo" href="/static/doc/index.html">
             
            <img alt="" src="../assets/css/logo.png" title="">
            
                
          </a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                 <ul class="nav navbar-nav">
                    
                    <li><a href="/home/index/index">首页</a>
                    </li>
                    
                    <li><a href="/static/doc/index.html">文档</a>
                    </li>
                    
                    <li><a href="/admin/index/index">演示</a>
                    </li>
                    
                    <li><a href="/home/index/log">日志</a>
                    </li>
                    
                </ul>
               <div class="navbar-form navbar-right filterAPi" autocomplete="off">
                <input type="text" id='txtSearchAPI' class="form-control search-query" placeholder="Search for API" />
                 <ul id="filterList" class="filterItems dropdown-menu" role="menu"></ul>
                </div>
            </div>
        </div>
    </nav>
    <div id="sidebar">
    <h3>Modules/Classes</h3>
        <div id="api-tabview-filter">
            <input id='txtSearch' type="search" class="form-control" placeholder="Type to filter Modules/Classes">
        </div>
        <dl id="sidebar_list">
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/admin.controller.html">admin.controller</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/admin.controller.base.html">admin.controller.base</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.controller.code.html">admin.controller.code</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.controller.index.html">admin.controller.index</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.controller.mob.html">admin.controller.mob</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/admin.model.html">admin.model</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/admin.model.code.html">admin.model.code</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.code_list.html">admin.model.code_list</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.groupuser.html">admin.model.groupuser</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.groupuser_add.html">admin.model.groupuser_add</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.log.html">admin.model.log</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.login.html">admin.model.login</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.privilege.html">admin.model.privilege</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.teamuser.html">admin.model.teamuser</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.teamuser_add.html">admin.model.teamuser_add</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/admin.model.user.html">admin.model.user</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/cmpage.controller.html">cmpage.controller</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/cmpage.controller.base.html">cmpage.controller.base</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.mob.html">cmpage.controller.mob</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.module.html">cmpage.controller.module</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.page.html">cmpage.controller.page</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.controller.utils.html">cmpage.controller.utils</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/cmpage.logic.html">cmpage.logic</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/cmpage.logic.page.html">cmpage.logic.page</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
                <dt>
                    <span class="glyphicon glyphicon-minus"></span>
                    <a href="../modules/cmpage.model.html">cmpage.model</a>
                </dt>
                <dd>
                    <ul>
                   
                       <li>
                            
                           <a href="../classes/cmpage.model.area.html">cmpage.model.area</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page.html">cmpage.model.page</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page_excel.html">cmpage.model.page_excel</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page_lookup.html">cmpage.model.page_lookup</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.page_mob.html">cmpage.model.page_mob</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.model.utils.html">cmpage.model.utils</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                       <li>
                            
                           <a href="../classes/cmpage.cmpage_global.html">cmpage.cmpage_global</a>
                           <ul>
                                
                           </ul>
                       </li>
                    
                    </ul>
                </dd>
             
        </dl>
</div>
   
    <div class="stdoc-content">
        <!--     <form id="options-form" class="form-inline pull-right">
        Show:
        <label for="api-show-inherited" class="checkbox">
            <input type="checkbox" id="api-show-inherited" checked>
            Inherited
        </label>

        <label for="api-show-protected" class="checkbox">
            <input type="checkbox" id="api-show-protected">
            Protected
        </label>

        <label for="api-show-private" class="checkbox">
            <input type="checkbox" id="api-show-private">
            Private
        </label>
        <label for="api-show-deprecated" class="checkbox">
            <input type="checkbox" id="api-show-deprecated">
            Deprecated
        </label>

    </form>

 -->
        <div class="apidocs">
            <div id="docs-main">
                <div class="content">
                    <div class="page-header">
    <h1>src\cmpage\model\page_rec.js <small>File</small></h1>
</div>

<div class="file">
    <pre class="prettyprint linenums" id='src_code'>
&#x27;use strict&#x27;;
// +----------------------------------------------------------------------
// | CmPage [ 通用页面框架 ]
// +----------------------------------------------------------------------
// | Licensed under the Apache License, Version 2.0
// +----------------------------------------------------------------------
// | Author: defans &lt;defans@sina.cn&gt;
// +----------------------------------------------------------------------

/**
 * page_rec model 实现主从表页面的编辑和查看
 */
import CMPage from &#x27;./page.js&#x27;;

export default class extends CMPage {
    /**
     * 取列表中按钮的设置，组合成HTML输出
     */
    async htmlGetBtnList(rec,page,pageBtns){
      let html=[];
      let pageCols = await global.model(&#x27;cmpage/module&#x27;).getModuleCol(page.id);
      for(let col of pageCols){
        if (col.c_isview) {
          html.push(&#x60;${col.c_column}:&#x27;${rec[col.c_column]}&#x27;&#x60;);
        }
      }
        //global.debug(html.join(&#x27;,&#x27;));
      return &#x60; &lt;a href=&quot;javascript:;&quot; data-toggle=&quot;lookupback&quot; data-args=&quot;{${html.join(&#x27;,&#x27;)}}&quot; class=&quot;btn btn-blue&quot; title=&quot;选择本项&quot; data-icon=&quot;check&quot;&gt;选择&lt;/a&gt;&#x60;;
    }

    htmlGetTabs(page){
        let tabs = page.c_module_rec.split(&#x27;,&#x27;);
        let html =[];
        html.push( &#x60;    &lt;div id=&quot;rec${page.c_modulename}Div&quot; &gt;
            &lt;fieldset&gt;
            &lt;legend&gt;-&lt;/legend&gt;
            &lt;ul class=&quot;nav nav-tabs&quot; role=&quot;tablist&quot;&gt;&#x60;);

        for(let tab of tabs){
            let rec = tab.split(&#x27;:&#x27;);           //如： DocuArriveRec:物料明细:c_docu
            let i = tabs.indexOf(tab);
            html.push(&#x60;&lt;li ${ i===0 ? &quot;class=active&quot;:&quot;&quot;}&gt;&lt;a href=&quot;#rec${page.c_modulename}List${i}&quot; role=&quot;tab&quot; data-toggle=&quot;tab&quot;&gt;${rec[1]}&lt;/a&gt;&lt;/li&gt;&#x60;);
        }

        html.push(&#x60;&lt;/ul&gt; &lt;!-- Tab panes --&gt; &lt;div class=&quot;tab-content&quot;&gt;&#x60;);

        for(let tab of tabs){
            let rec = tab.split(&#x27;:&#x27;);
            let i = tabs.indexOf(tab);
            html.push(&#x60;&lt;div class=&quot;tab-pane fade ${i ==0 ? &quot;active in&quot;:&quot;&quot;}&quot; id=&quot;rec${page.c_modulename}List${i}&quot;  name=&quot;rec${page.c_modulename}List${i}&quot;
                dataurl=&quot;/cmpage/page/list?modulename=${rec[0]}&amp;${rec[2]}=${page.editID}&amp;page_rec_view_flag=false&quot; &gt;  &lt;/div&gt;&#x60;);
        }

        html.push(&#x27;&lt;/div&gt;   &lt;/fieldset&gt;   &lt;/div&gt;&#x27;);

        return html.join(&#x27; &#x27;);
    }

    htmlGetJS(page) {
        let tabs = page.c_module_rec.split(&#x27;,&#x27;);
        html = [];
        html.push(&#x60; &lt;script type=&quot;text/javascript&quot;&gt;
         function rec${page.c_modulename}Appr_onClick(flowID,action){
            $(this).alertmsg(&quot;confirm&quot;, &quot;是否确定要&quot;+action+&quot;？&quot;,{
                okCall:function(){
                    $.ajax({
                        type: &quot;POST&quot;,
                        url: &quot;/cmpage/page/edit_rec_appr&quot;,
                        data: &quot;docuID=${page.editID}&amp;flowID=&quot;+flowID +&quot;&amp;note=&quot;+$(&quot;#${page.c_modulename}_c_note&quot;).val()
                        +&quot;&amp;tableName=${page.c_table}&amp;parms=${page.parmsUrl}&quot;+&quot;&amp;moduleName=${page.c_modulename}&quot;,
                        async: false,
                        success: function (data) {
                            var ret =eval(&quot;(&quot;+data+&quot;)&quot;);
                            $(this).alertmsg(ret.statusCode==&quot;200&quot; ? &quot;info&quot;:&quot;error&quot;,ret.message);
                            if(ret.statusCode==&quot;200&quot;)
                            {
                                $.CurrentNavtab.navtab(&#x27;reload&#x27;, { })
                            }
                        }
                    });
                }
            });

            return false;
        } &lt;/script&gt;&#x60;);

        html.push(&#x60;&lt;script type=&quot;text/javascript&quot;&gt;
        function rec${page.c_modulename}Save_onClick(){
            $.ajax({
                type: &quot;POST&quot;,
                url: &quot;/cmpage/page/save&quot;,
                data: $(&quot;#rec${page.c_modulename}Form&quot;).serialize(),
                async: false,
                success: function (data) {
                    var ret =eval(&quot;(&quot;+data+&quot;)&quot;);
                    $(this).alertmsg((ret.statusCode==&quot;200&quot; ? &quot;info&quot;:&quot;error&quot;),ret.message);
                    if(ret.statusCode==&quot;200&quot;)
                    {
                        if(ret.newID &gt;0)
                        {
                            $(&quot;#rec${page.c_modulename}ID&quot;).val(ret.newID);
                            $.CurrentNavtab.navtab(&#x27;reload&#x27;, { url:&quot;/cmpage/page/edit_rec?modulename=${page.c_modulename}&amp;id=&quot;+ret.newID, type:&quot;GET&quot;, onLoad:&quot;rec${page.c_modulename}List_load2&quot;})
                        }
                    }
                }
            });
        } &lt;/script&gt;&#x60;);

        html.push(&#x60;&lt;script type=&quot;text/javascript&quot;&gt;
            function rec${page.c_modulename}List_load2(){
                var id = $(&quot;#rec${page.c_modulename}ID&quot;).val();
                &#x60;);

        for(let tab of tabs){
            let rec = tab.split(&#x27;:&#x27;);           //如： DocuArriveRec:物料明细:c_docu
            let i = tabs.indexOf(tab);
            html.push(&#x60;$(this).bjuiajax(&#x27;doLoad&#x27;, {target:$(&quot;#rec${page.c_modulename}List${i}&quot;), url:&quot;/cmpage/page/list?modulename=${rec[0]}&amp;${rec[2]}=${page.editID}&amp;page_rec_view_flag=false&quot; });&#x60;);
        }

        html.push(&#x27;}&lt;/script&gt;&#x27;);
        return html.join(&#x27; &#x27;);
    }
}

    </pre>
</div>

                </div>
            </div>
        </div>
    </div>
<a id="gotoTop" class='well well-small' href='#'>
    Top
</a>
<script src="../assets/vendor/jquery/jquery-1.8.2.min.js"></script>
<script src="../assets/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script src="../assets/js/config.js"></script>
<script src="../assets/js/doc.js"></script>
</body>
</html>
